import { Language } from "../../../../../extend/language/Language";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { MountAddValue } from "../../../rules/MountAddValue";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { EJewel } from "../../../../../Message/Public/EJewel";
import { ItemData } from "../../../resource/info/ItemData";
type int = number;
//class MountsToolTipUtil
    
    export  class MountsToolTipUtil
    {
        

        public static getSpeedText(): string
        {
            var loc1="";
            var loc2=MountsToolTipUtil.itemData.itemExInfo;
            if (loc2 == null) 
            {
                loc1 = loc1 + Language.getStringByParam(90207, Math.floor(MountsToolTipUtil.itemData.itemInfo.extend.baseSpeed - 100 + (MountsToolTipUtil.itemData.itemInfo.extend.initLevel - 1) * MountsToolTipUtil.speedValue()).toString());
            }
            else 
            {
                loc1 = loc1 + Language.getStringByParam(90207, (loc2.speed - 100).toString());
            }
            return HTMLUtil.addColor(loc1, "#f0ea3f");
        }

        /* internal  */static speedValue(): number
        {
            var loc1=MountsToolTipUtil.itemData.color;
            switch (loc1) 
            {
                case 1:
                {
                    return 0.55;
                }
                case 2:
                {
                    return 0.65;
                }
                case 3:
                {
                    return 0.8;
                }
                case 4:
                {
                    return 0.95;
                }
                case 5:
                {
                    return 1.2;
                }
            }
            return 1;
        }

        public static getAddtionalProps(): string
        {
            var loc3=0;
            var loc6=0;
            var loc7=null;
            var loc8=0;
            var loc9=null;
            var loc1=MountsToolTipUtil.itemData.itemInfo.item;
            var loc2="";
            var loc4=false;
            var loc5;
            if ((loc5 = MountsToolTipUtil.getAddtionalArray()).length == 0) 
            {
                if (MountsToolTipUtil.itemData.uid == null) 
                {
                    loc4 = true;
                    loc3 = (loc1.color - 1);
                    while (loc6 < loc3) 
                    {
                        (loc7 = new Map<any, any> /* flash.utils.Dictionary */())["key"] = 0;
                        loc7["name"] = "？？";
                        loc7["value"] = "？？？";
                        loc5.push(loc7);
                        ++loc6;
                    }
                }
            }
            if (loc5.length > 0) 
            {
                loc2 = HTMLUtil.addColor(Language.getString(90213), "#f0ea3f");
            }
            loc6 = 0;
            while (loc6 < loc5.length) 
            {
                loc9 = loc5[loc6] as Map<any, any> /* flash.utils.Dictionary */;
                if (loc4) 
                {
                    loc2 = loc2 + ("\r    " + loc9["name"] + "   " + loc9["value"]);
                }
                else if (loc9["name"].length != 2) 
                {
                    loc2 = loc2 + ("\r    " + loc9["name"] + "" + loc9["value"]);
                }
                else 
                {
                    loc2 = loc2 + ("\r    " + loc9["name"] + "  " + loc9["value"]);
                }
                ++loc6;
            }
            if (loc2 != "") 
            {
                loc2 = "<textFormat leading=\'5\'>" + HTMLUtil.addColor(loc2, MountAddValue.getColorValue(loc9["key"], loc9["value"])) + "</textFormat>";
            }
            return loc2;
        }

        /* internal  */static getAddtionalArray(): Array<any>
        {
            var loc7=0;
            var loc8=null;
            var loc9=null;
            var loc1=MountsToolTipUtil.itemData.itemInfo.item;
            var loc2=MountsToolTipUtil.itemData.itemExInfo;
            var loc3=[];
            if (loc1.color <= 1) 
            {
                return loc3;
            }
            var loc4=[];
            var loc5=[];
            if (loc2) 
            {
                loc4.push(loc2.addition1);
                loc4.push(loc2.addition2);
                loc4.push(loc2.addition3);
                loc4.push(loc2.addition4);
                loc5.push(loc2.addVal1);
                loc5.push(loc2.addVal2);
                loc5.push(loc2.addVal3);
                loc5.push(loc2.addVal4);
            }
            else 
            {
                loc3 = MountsToolTipUtil.getAddtionalByConfig();
                return loc3;
            }
            var loc6=0;
            while (loc6 < loc4.length) 
            {
                if ((loc7 = loc4[loc6]) > 0) 
                {
                    loc8 = new Map<any, any> /* flash.utils.Dictionary */();
                    loc9 = GameDefConfig.instance.getEJewel(loc7);
                    loc8["key"] = loc7;
                    if (loc9) 
                    {
                        loc8["name"] = loc9.name;
                    }
                    else 
                    {
                        loc8["name"] = "";
                    }
                    loc8["value"] = loc5[loc6];
                    loc3.push(loc8);
                }
                ++loc6;
            }
            return loc3;
        }

        /* internal  */static getAddtionalByConfig(): Array<any>
        {
            var loc1=[];
            MountsToolTipUtil.buildAddtion(loc1, "life", EJewel._EJewelLife);
            MountsToolTipUtil.buildAddtion(loc1, "jouk", EJewel._EJewelJouk);
            if (loc1.length > (MountsToolTipUtil.itemData.color - 1)) 
            {
                return [];
            }
            return loc1;
        }

        /* internal  */static buildAddtion(arg1: Array<any>, arg2: string, arg3: int): void
        {
            var loc1=null;
            var loc2=null;
            var loc3;
            if ((loc3 = MountsToolTipUtil.itemData.itemInfo.extend[arg2] as string) == null || loc3 == "") 
            {
                return;
            }
            if ((loc1 = loc3.split(",")).length == 2) 
            {
                if (loc1[0] == loc1[1] && !(loc1[0] == 0)) 
                {
                    (loc2 = new Map<any, any> /* flash.utils.Dictionary */())["key"] = arg3;
                    loc2["name"] = GameDefConfig.instance.getEJewel(arg3).name;
                    loc2["value"] = loc1[0];
                    arg1.push(loc2);
                }
            }
            return;
        }

        public static /* var */itemData: ItemData;
    }
